package com.example.diethealthsystem.service;

import com.example.diethealthsystem.entity.Food;
import com.example.diethealthsystem.repository.FoodRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class FoodService {

    private final FoodRepository foodRepository;

    @Autowired
    public FoodService(FoodRepository foodRepository) {
        this.foodRepository = foodRepository;
    }

    public List<Food> findAll() {
        return foodRepository.findAll();
    }

    public Optional<Food> findById(Long id) {
        return foodRepository.findById(id);
    }

    public Food save(Food food) {
        return foodRepository.save(food);
    }

    public void deleteById(Long id) {
        foodRepository.deleteById(id);
    }

    public Optional<Food> findByNameContainingIgnoreCase(String name) {
        return foodRepository.findByNameContainingIgnoreCase(name);
    }

    public List<Food> findByName(String name) {
        return foodRepository.findByName(name);
    }
} 